package com.kkwrite.regimen.common.constant;

/**
 * Created by lisha on 2018/7/16 11:16.
 *
 * @author lisha
 */
public enum GenderEnum {
    /**
     * 性别未知
     */
    UNKNOWN("未知", 0),
    /**
     * 男
     */
    MALE("男", 1),
    /**
     * 女
     */
    FEMALE("女", 2)
    ;

    private String gender;
    private Integer value;

    GenderEnum(String gender, Integer value) {
        this.gender = gender;
        this.value = value;
    }

    public String getGender() {
        return this.gender;
    }

    public Integer getValue() {
        return this.value;
    }

    public static Integer findValue(String gender) {
        if (gender == null || gender.isEmpty()) {
            return GenderEnum.UNKNOWN.getValue();
        }
        for (GenderEnum anGender : GenderEnum.values()) {
            if (gender.equals(anGender.getGender())) {
                return anGender.getValue();
            }
        }
        return GenderEnum.UNKNOWN.getValue();
    }

    public static String findGender(int value) {
        for (GenderEnum genderEnum : GenderEnum.values()) {
            if (genderEnum.getValue() == value) {
                return genderEnum.getGender();
            }
        }
        return GenderEnum.UNKNOWN.getGender();
    }

}
